﻿#include <iostream>
#include <QObject>
#include <QTimer>
#include <QThread>
#include <QApplication>


class Test : public QThread
{
	Q_OBJECT
public:
	Test(QObject* parent = nullptr);
	~Test();

protected:
	void run() override {
		m_timer = new QTimer;
		m_timer->setSingleShot(true);
		connect(m_timer, &QTimer::timeout, this, [&]() {
			std::cout << "123";
			m_timer->start(2000);
			});
		m_timer->start(2000);
		exec();
	}

private:
	QTimer* m_timer = nullptr;
};

Test::Test(QObject* parent)
	: QThread(parent)
{
	moveToThread(this);
}

Test::~Test()
{
}

int main(int argc, char* argv[])
{
	Test* test = new Test;
	test->start();

	QApplication app(argc, argv);
	app.exec();
	return 1;
}
#include "main.moc"
